<template>
    <div class="title">图书商城后台管理系统</div>
    <el-menu router class="el-menu-vertical" default-active="/home" :collapse="isCollapsed">
        <el-menu-item index="/home">
            <el-icon>
                <House />
            </el-icon>
            <template #title>首页</template>
        </el-menu-item>
        <el-menu-item index="/user-manage">
            <el-icon><User /> </el-icon>
            <template #title> 用户管理 </template>
        </el-menu-item>
        <el-sub-menu index="/book-manage">
            <template #title>
                <el-icon><Collection /></el-icon>
                <span>图书管理</span>
            </template>
            <el-menu-item index="/book-manage/detail">图书信息</el-menu-item>
            <el-menu-item index="/book-manage/add">添加图书</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="/order-manage">
            <template #title>
                <el-icon><DocumentCopy /></el-icon>
                <span>订单管理</span>
            </template>
            <el-menu-item index="/order-manage/send">订单发货</el-menu-item>
            <el-menu-item index="/order-manage/shipping">配送中订单</el-menu-item>
            <el-menu-item index="/order-manage/confirm">已完成订单</el-menu-item>
        </el-sub-menu>
        <el-menu-item index="/category-manage">
            <el-icon>
                <Menu />
            </el-icon>
            <template #title>分类管理</template>
        </el-menu-item>
    </el-menu>
</template>

<script setup>
import { Collection, DocumentCopy, House, Menu, User } from "@element-plus/icons-vue";
import { onBeforeMount, ref, watch } from "vue";
import { menuStore } from "@/store/menu";

const menu = menuStore();
const isCollapsed = ref(false);

// 监听pinia中的数据
watch(
    () => menu.isCollapsed,
    (newVal) => {
        isCollapsed.value = newVal;
        // console.log(isCollapsed)
    }
);
</script>

<style lang="scss" scoped>
.title {
    position: relative;
    text-align: center;
    height: 60px;
    padding: 20px 0;
    color: var(--el-text-color-primary);
    font-weight: bold;
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.el-menu {
    border-right: none;
    --el-menu-text-color: var(--el-text-color-secondary);
    --el-menu-active-color: var(--el-text-color-primary);
    --el-menu-bg-color: var(--el-fill-color-darker);
}
</style>
